import request from '@/utils/request'

// 查询课程列表
export function listLesson() {
  return request({
    url: `/train/lesson/listByUserId`,
    method: 'get'
  })
}

// 查询课程详细
export function getLesson(lessonId) {
  return request({
    url: '/train/lesson/' + lessonId,
    method: 'get'
  })
}

// 新增课程
export function addLesson(data) {
  return request({
    url: '/train/lesson',
    method: 'post',
    data: data
  })
}

// 修改课程
export function updateLesson(data) {
  return request({
    url: '/train/lesson',
    method: 'put',
    data: data
  })
}

// 删除课程
export function delLesson(lessonId) {
  return request({
    url: '/train/lesson/' + lessonId,
    method: 'delete'
  })
}

// 查询教师角色用户
export function getTeachers() {
  return request({
    url: '/system/user/byRoleId/3',
    method: 'get',
  })
}

// 修改课程发布状态
export function changeStatus(lessonId, status, version) {
  const data = {
    lessonId,
    status,
    version
  }
  return request({
    url: '/train/lesson/changeStatus',
    method: 'put',
    data: data
  })
}

// 排序
export function homeSortApi(data) {
  return request({
    url: '/train/lesson/sort',
    method: 'put',
    params: data
  })
}
